from machine import Pin
from time import sleep

led = Pin(2,Pin.OUT)
switch = Pin(4,Pin.IN)

def button_deal():
    if(led.value() > 0):
        led.off()
    else:
        led.on()
    print("valid btn")
    
    
while True:
    if(switch.value() > 0):
        sleep(0.03)
        if(switch.value()>0):
            toggle()
            while switch.value():
                pass
        else:
            pass
    else:
        pass
    sleep(0.1)